<?php
/**
 * Created by PhpStorm.
 * User: ASUS
 * Date: 2020/12/2
 * Time: 14:12
 */

namespace app\pcapi\controller;


class Index extends Base
{
    /**
     * @author ASUS
     * @date 2020-12-03 11:45
     * 进量统计
     */

    public function index()
    {
        $cache = cache(input("admin"));
        if($cache["id"]==1) {//超管
            $where = [];
        }else{//各自盘
            $where[] = ["admin_id","=",$cache["id"]];
        }
        $where[] = ["status",'=',1];
        $start = strtotime(date("Y-m-d 00:00:00"));
        $end = strtotime(date("Y-m-d 23:59:59"));
        $where[] = ["add_time",'>=',$start];
        $where[] = ["add_time",'<=',$end];
        $map[] = ["paymethod","like","%dkpay%"];
        //查询数kayapay
        $kaya_df_amount = db("df")->where($where)->where(["paymethod"=>"dkpay"])->sum("k_amount");//kaya当天的代付总金额
        $kaya_df_num = db("df")->where($where)->where(["paymethod"=>"dkpay"])->count();//kaya当天的代付总笔数
        $kaya_zf_amount = db("zf")->where($where)->where($map)->sum("r_amount");//kaya当天的支付总金额
        $kaya_zf_num = db("zf")->where($where)->where($map)->count();//kaya当天的支付总笔数
        $data = [
            [
                "name"=>"dkpay",
                "df_amount"=>$kaya_df_amount,
                "df_num"=>$kaya_df_num,
                "zf_amount"=>$kaya_zf_amount,
                "zf_num"=>$kaya_zf_num,
            ]
        ];
        api_return(200,"成功",$data);
    }
}